// run: $exec < input
#include <iostream>
#include <vector>
#include <cstring>
#include <utility>

int const maxn = 4007;
int const inf = 1 << 27;
bool map[maxn][maxn];
int count[maxn];
int n, m;

std::vector<int> graph[maxn];
std::vector<std::pair<int, int>> edge;

int main()
{
	std::ios::sync_with_stdio(false);
	std::cin >> n >> m;
	edge.resize(m);
	for (int i = 0, x, y; i < m; i++) {
		std::cin >> x >> y;
		map[x][y] = map[y][x] = true;
		count[x]++; count[y]++;
		edge[i].first = x;
		edge[i].second = y;
	}
	int ans = inf;
	for (int i = 0; i < m; i++) {
		int u = edge[i].first, v = edge[i].second;
		for (int j = 0; j < n; j++)
			if (map[u][j] && map[v][j]) {
				ans = std::min(ans, count[u] + count[v] + count[j] - 6);
			}
	}
	if (ans == inf) ans = -1;
	std::cout << ans << '\n';
}

